package ab.mes.controller;

import ab.mes.service.WorkingService;
import ab.mes.tools.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/working")
public class WorkingController {

    @Autowired
    private WorkingService workingService;

    //查询所有工序名称和图片
    @PostMapping("/selectWorking1")
    public Result selectWorking1(){
        Result result=new Result();
        try {
            result = workingService.selectWorking1();
        }catch (Exception e){
            result.setErrorMessage("查询工序失败！");
            e.printStackTrace();
        }
        return result;
    }
    @PostMapping("/selectByName")
    //根据工序名称查询所有名称和图片
    public Result selectByName(String process_name){
        Result result=new Result();
        try {
            result = workingService.selectByName(process_name);
        }catch (Exception e){
            result.setErrorMessage("查询工序失败！");
            e.printStackTrace();
        }
        return result;
    }
    //切换是否打印状态
    @PostMapping("/updatePrintByName")
    public Result updatePrintByName(String process_name){
        Result result=new Result();
        try {
            result = workingService.updatePrintByName(process_name);
        }catch (Exception e){
            result.setErrorMessage("更改状态失败！");
            e.printStackTrace();
        }
        return result;
    }
    //切换是否首件检查状态
    @PostMapping("/updateCheckByName")
    public Result updateCheckByName(String process_name){
        Result result=new Result();
        try {
            result = workingService.updateCheckByName(process_name);
        }catch (Exception e){
            result.setErrorMessage("更改状态失败！");
            e.printStackTrace();
        }
        return result;
    }


}
